package ace.cmp.security.oauth2.authz.server.test.autoconfig;

import ace.cmp.security.oauth2.authz.server.test.core.controller.Oauth2ServerTestController;
import ace.cmp.security.oauth2.authz.server.test.core.properties.Oauth2ServerTestProperties;
import lombok.AllArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author caspar
 * @date 2023/2/6 20:09 自动配置通用安全组件
 */
@ConditionalOnProperty(
    prefix = Oauth2ServerTestProperties.CONFIG_PREFIX,
    value = "enable",
    havingValue = "true",
    matchIfMissing = false)
@EnableConfigurationProperties({Oauth2ServerTestProperties.class})
@AllArgsConstructor
@Configuration
public class SecurityOauth2ServerTestAutoConfigure {
  private final Oauth2ServerTestProperties properties;

  @Bean
  public Oauth2ServerTestController oAuth2AuthzTestController() {
    return new Oauth2ServerTestController(properties);
  }
}
